#   引入suds模块
from suds.client import Client

#   即将访问的web service的地址, 注意, 一定是wsdl页面
url = 'http://ws.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl'
#   Client里面直接放访问的URL，可以生成一个webservice对象
client = Client(url)
#   打印接口的信息
# print(client)

#   为string类型的参数赋值
theIpAddress = '42.156.141.13'
#   调用getCountryCityByIp接口
result = client.service.getCountryCityByIp(theIpAddress)
#   打印结果
print(result)

if '北京市' in result:
    print('响应正确.')
else:
    print('获取响应失败')

# data = {'theIpAddress': '42.156.141.13'}
# result = client.service.getCountryCityByIp(data)

# print(result)


#   https://www.cnblogs.com/liulinghua90/p/5823021.html
#   http://www.chengxuyuans.com/Python/64773.html
#   http://blog.csdn.net/jingqia/article/details/17398673
